import * as echarts from "../../../assets/echarts/echarts.esm.js";
export default {
    template:`
        <div ref="chart"></div>
    `,
    props:{
        option:{
            type:Object,
            default(){
                return {}
            }
        }
    },
    watch: {
        option:{
            handler(){
                this.$myChart.setOption(this.option)
            },
            deep:true
        }
    },
    methods: {
        initEcharts() {
            this.$myChart = echarts.init(this.$refs.chart)
            this.$myChart.setOption(this.option)
        },
        showLoading(){
            this.$myChart.showLoading()
        },
        hideLoading(){
            this.$myChart.hideLoading()
        }
    },
    mounted () {
        this.initEcharts();
    }
}